package com.ybq.library.service;

/**
 * @author : Ybq777
 * @version : 1.0.0
 * @description :
 * @createTime : 2024/12/2 16:57
 */

import com.ybq.library.dao.YbqBookMapper;
import com.ybq.library.dao.YbqUserMapper;
import com.ybq.library.entity.YbqBook;
import com.ybq.library.entity.YbqUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class YbqBookService {

    private final YbqBookMapper bookMapper;
    @Autowired
    public YbqBookService(YbqBookMapper bookMapper) {
        this.bookMapper = bookMapper;
    }
    // 新增图书信息业务逻辑
    public void addBook(YbqBook book) {
        bookMapper.insertBook(book);
    }

    // 删除图书信息业务逻辑，需验证权限（这里假设在调用处已验证）
    public void deleteBookById(String bookId) {
        bookMapper.deleteBookById(bookId);
    }

    // 修改图书信息业务逻辑，需验证权限（这里假设在调用处已验证）
    public void updateBook(YbqBook book) {
        bookMapper.updateBook(book);
    }

    // 按单条件查询图书信息业务逻辑
    public YbqBook getBookBySingleCondition(String condition, Object value) {
        return bookMapper.selectBookBySingleCondition(condition, value);
    }

    // 按多条件查询图书信息业务逻辑
    public List<YbqBook> getBooksByMultipleConditions(String bookName, String bookType, double minPrice, double maxPrice) {
        return bookMapper.selectBooksByMultipleConditions(bookName, bookType, minPrice, maxPrice);
    }

    // 查询所有book逻辑
    public List<YbqBook> getAllBooks() {
        return bookMapper.selectAllBooks();
    }

}